package cn.zjitc.ptaLearn.ch07.ex09;
import java.util.Scanner;

/**
 * @author Zixuan Xu
 * @date
 */
/*
    为学生类添加属性成绩，添加相应的get和set函数，
    添加函数getGrade()表示获得等级，该函数应当为抽象函数。
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sid1 = sc.nextInt();
        String name1 = sc.next();
        String sex1 = sc.next();
        String major1 = sc.next();
        int grade1 = sc.nextInt();
        Student s1 = new Graduate(sid1, name1, sex1, major1, grade1);
        s1.getGrade(grade1);

        int sid2 = sc.nextInt();
        String name2 = sc.next();
        String sex2 = sc.next();
        String major2 = sc.next();
        String teacher = sc.next();
        int grade2 = sc.nextInt();
        Student s2 = new postGraduate(sid2, name2, sex2, major2, teacher, grade2);
        s2.getGrade(grade2);
    }
}

abstract class Student {
    private int sid;
    private String name;
    private String sex;
    private String major;
    private int grade;
    public Student() {
    }

    public Student(int sid, String name, String sex, String major, int grade) {
        this.sid = sid;
        this.name = name;
        this.sex = sex;
        this.major = major;
        this.grade = grade;
    }

    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public void setGrade(int grade) {
        this.grade = grade;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }
    abstract void getGrade(int grade);

}

class postGraduate extends Student {

    private String teacher;
    public postGraduate(){}

    public postGraduate(int sid, String name, String sex, String major,String teacher, int grade) {
        super(sid, name, sex, major, grade);
        this.teacher=teacher;
    }

    public String getTeacher() {
        return teacher;
    }

    public void setTeacher(String teacher) {
        this.teacher = teacher;
    }

    @Override
    void getGrade(int grade) {
        if(grade>=90){
            System.out.println("A");
        }else if(grade>=80){
            System.out.println("B");
        }else if(grade>=70){
            System.out.println("C");
        }else if(grade>=60){
            System.out.println("D");
        }else {
            System.out.println("E");
        }
    }
}

class Graduate extends Student {
    public Graduate() {
    }

    public Graduate(int sid, String name, String sex, String major, int grade) {
        super(sid, name, sex, major, grade);
    }

    @Override
    void getGrade(int grade) {
        if(grade>=80){
            System.out.println("A");
        }else if(grade>=70){
            System.out.println("B");
        }else if(grade>=60){
            System.out.println("C");
        }else if(grade>=50){
            System.out.println("D");
        }else{
            System.out.println("E");
        }
    }
}
